<?php
namespace app\common\model;

class LiveZans extends Common
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'ctime';
    /**
     * 点赞
     */
    public function onZans($data){
        $view=$this->where(['room_id'=>$data['room_id'],'live_id'=>$data['live_id'],'uid'=>$data['uid']])->find();
        if(!$view){
            $this->create($data);
        }
        #更新直播间
        Room::where('id',$data['room_id'])->setInc('zans',1);
        #更新直播点赞
        Live::where('id',$data['live_id'])->setInc('zans',1);
        return [true,'success'];
    }

}
